﻿#region LGPL Header
/* This file is part of ErrorProviders.

    ErrorProviders is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    ErrorProviders is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with ErrorProviders; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  
*/
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace DemoApp
{
    public static class ValidateMethodCollection
    {
        public static bool GenericValidateMethod(UIElement element)
        {
            if (element is TextBox)
            {
                return !string.IsNullOrEmpty(((TextBox)element).Text);
            }
            else if (element is ComboBox)
            {
                return ((ComboBox)element).SelectedItem != null;
            }


            //Return true as default
            return true;
        }

        public static bool PasswordValidateMethod(UIElement element)
        {
            if (element is PasswordBox)
            {
                return (!string.IsNullOrEmpty(((PasswordBox)element).Password) && ((PasswordBox)element).Password.Length > 4);
            }


            return true;
        }
    }
}
